#define _CRT_SECURE_NO_WARNINGS	

#include<stdio.h>

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    printf(" Sun Mon Tue Wed Thu Fri Sat\n");
    for (int i = 0; i < b % 7; i++)
        printf("    ");
    int count = b;
    for (int i = 1; i <= a; i++)
    {
        printf("%4d", i);
        count++;
        if (count % 7 == 0)
            printf("\n");
    }
    return 0;
}